<template>
  <c-back-wrap :loading="loading" go-page="经销商档案新建管理" current-page="详情">
    <QupList :column="3" sep="：" default-value="" label-position="right" label-width="160">
      <QupListItem label="办事处" :value="detail.officeName" />
      <QupListItem label="办事处类别" :value="detail.officeTypeName" />
      <QupListItem label="办事处负责人" :value="detail.personName" />
      <QupListItem label="是否需要其他业务客户经理接收知晓" :value="detail.isOtherReceiveManagerKnow" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" label-width="220px" />
      <template v-if="[1,'1'].includes(detail.isOtherReceiveManagerKnow)">
        <QupListItem label="接收客户经理" :value="detail.receiveManagerCode" />
        <QupListItem label="接收客户经理名称" :value="detail.receiveManagerName" />
        <QupListItem label="接收客户经理类型" :value="detail.receiveManagerTypeName" />
        <QupListItem label="接收客户经理电话" :value="detail.receiveManagerTel" />
      </template>
    </QupList>
    <c-title title="经销商基本信息">
      <QupList :column="3" sep="：" default-value="" label-position="right" label-width="130">
        <QupListItem label="经销商编码" :value="detail.customerCode" />
        <QupListItem label="经销商系统名称" :value="detail.customerName" />
        <QupListItem label="经销商姓名" :value="detail.legalPerson" />
        <QupListItem label="经销商身份证号" :value="detail.credentialNo" />
        <!-- <QupListItem label="身份证详细地址" :value="detail.disAddr" /> -->
        <QupListItem label="合作起始日期" :value="$trimHMS(detail.cooperateStart)" />
        <QupListItem label="是否缴纳保证金" :value="detail.isDeposit" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <QupListItem v-if="[1, '1'].includes(detail.isDeposit)" label="保证金缴纳日期" :value="$trimHMS(detail.depositDate)" />
        <QupListItem label="成品保证金金额(元)" :value="`${detail.finishedDeposit || 0}`" />
        <QupListItem label="定制保证金金额(元)" :value="`${detail.customizedDeposit || 0}`" />
        <QupListItem label="橱柜保证金金额(元)" :value="`${detail.cupboardDeposit || 0}`" />
        <QupListItem label="卫浴保证金金额(元)" :value="`${detail.bathroomDeposit || 0}`" />
        <QupListItem label="身份证正面图片" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS050" />
        </QupListItem>
        <QupListItem label="身份证反面图片" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS051" />
        </QupListItem>
        <QupListItem label="资金安全告知函" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS052" />
        </QupListItem>
        <QupListItem label="签字签章函" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS053" />
        </QupListItem>
        <QupListItem label="收货地址确认单" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS054" />
        </QupListItem>
      </QupList>
    </c-title>
    <c-title title="经销商-收货地址">
      <AddrTable :table-data="detail.addressDTOS" type="view" />
    </c-title>
    <c-title title="经销商-联系人">
      <ContactsTable title="经销商-联系人" :table-data="(detail.contactDTOS || []).filter(e => [1,'1'].includes(e.contactScope))" type="view" />
    </c-title>
    <c-title>
      <div slot="title" style="display:flex;align-items:center;">
        <span class="title" style="margin-right: 5px">是否合伙经营</span>
        <!-- <span>{{ [1,'1'].includes(detail.isPartnership)?'是':'否' }}</span> -->
        <el-switch :value="detail.isPartnership" :active-value="1" :inactive-value="0" disabled />
      </div>
      <PartnershipTable v-show="[1,'1'].includes(detail.isPartnership)" title="合伙经营" :table-data="detail.partnerDTOS" />
    </c-title>
    <c-title title="交接信息">
      <QupList :column="1" sep="：" default-value="" label-position="right" label-width="140">
        <QupListItem label="是否经销商交接" :value="detail.isMarketConnect" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <template v-if="[1,'1'].includes(detail.isMarketConnect)">
          <QupListItem label-width="0" :span="24">
            <DistributionTable title="交接信息" :table-data="detail.handoverDTOS" type="view" :hidden-column="['fromShopCode', 'fromShopName']" />
          </QupListItem>
          <QupListItem label="经销商交接证明" :span="24">
            <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS058" />
          </QupListItem>
          <QupListItem label="经销商关系证明" :span="24">
            <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS059" />
          </QupListItem>
          <QupListItem label="交接双方现场签订照片" label-width="160px" :span="24">
            <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS111" />
          </QupListItem>
        </template>
      </QupList>
    </c-title>
    <c-title title="门店基本信息">
      <QupList v-if="isTakeOver" :column="1" sep="：" default-value="" label-position="right" label-width="130">
        <QupListItem label="是否接管原商家门店" :value="detail.isTakeOverTheOriginalStore" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <QupListItem :span="24">
          <c-title title="新增门店信息">
            <ShopTable ref="shopTable" :table-data="customerShopData" :is-edit="false" />
          </c-title>
          <c-title title="门店联系人">
            <ShopContactTable ref="shopContactTable" :table-data="shopContactsData" :shop-data="customerShopData" :is-audit="hasShop" :is-edit="false" />
          </c-title>
        </QupListItem>
      </QupList>
      <QupList v-else :column="3" sep="：" default-value="" label-position="right" label-width="150">
        <QupListItem label="门店编码" :value="shopDTO.code" />
        <QupListItem label="门店经营业务类型" :value="shopDTO.businessTypeName" :span="24/3*2" />
        <QupListItem label="门店名称" :value="shopDTO.name" />
        <QupListItem label="门店类型" :value="shopDTO.shopClassifyName" />
        <QupListItem label="国别" :value="shopDTO.countryName" />
        <QupListItem label="省份" :value="shopDTO.provinceName" />
        <QupListItem label="城市" :value="shopDTO.cityName" />
        <QupListItem label="区/县" :value="shopDTO.countyName" />
        <QupListItem label="街道/乡镇" :value="shopDTO.townName" />
        <QupListItem label="详细地址" :value="shopDTO.shopAddr" :span="24" />
        <QupListItem label="所在楼层" :value="shopDTO.floor" />
        <QupListItem label="城市级别" :value="shopDTO.cityLevelName" />
        <QupListItem label="市场层级" :value="shopDTO.marketLevelName" />
        <QupListItem label="门店咨询电话" :value="shopDTO.shopInfoPhone" />
        <QupListItem label="售后电话" :value="shopDTO.shopServPhone" />
        <QupListItem label="出图总面积(㎡)" :value="shopDTO.outpicArea || 0" />
        <QupListItem label="是否装修门头" :value="shopDTO.isDecorationDoorHead" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <!-- <QupListItem label="门头面积" :value="shopDTO.doorHeadArea" /> -->
        <QupListItem label="营业执照图片" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="shopDTO.id" view-type="list" type-code="ACCESS055" />
        </QupListItem>
        <QupListItem label="专卖店特许经营合同图片" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="shopDTO.id" view-type="list" type-code="ACCESS056" />
        </QupListItem>
        <QupListItem label="成品面积(㎡)" :value="shopDTO.endProductArea || 0" />
        <QupListItem label="全屋定制面积(㎡)" :value="shopDTO.fullHouseArea || 0" />
        <QupListItem label="整体橱柜面积(㎡)" :value="shopDTO.cabinetArea || 0" />
        <QupListItem label="卫浴面积(㎡)" :value="shopDTO.bathroomArea || 0" />
        <QupListItem label="样板间面积(㎡)" :value="shopDTO.modelRoomArea || 0" />
        <QupListItem label="窗帘面积(㎡)" :value="shopDTO.curtainArea || 0" />
        <QupListItem label="橱柜套数" :value="shopDTO.cabinetSuite" />
        <QupListItem label="卫浴套数" :value="shopDTO.bathroomSuite" />
        <QupListItem label="单店总面积(㎡)" :value="shopDTO.totalArea || 0" />
        <QupListItem label="门头类型" :value="shopDTO.headTypeName" />
        <QupListItem label="门头面积(㎡)" :value="shopDTO.doorHeadArea || 0" />
        <QupListItem label="门楣面积(㎡)" :value="shopDTO.lintelArea || 0" />
      </QupList>
    </c-title>
    <template v-if="!isTakeOver">
      <c-title title="门店联系人" :span="24">
        <ContactsTable title="门店联系人" :table-data="(detail.contactDTOS || []).filter(e => [3,'3'].includes(e.contactScope))" />
      </c-title>
      <c-title title="门店报图情况">
        <QupList :column="1" sep="：" default-value="" label-position="right" label-width="130">
          <QupListItem label="是否报图" :value="shopDTO.isReportPic" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
          <QupListItem v-if="![1,'1'].includes(shopDTO.isReportPic)" label="特殊建档附件" :span="24">
            <c-file-list :uploadable="false" :editable="false" :model-id="shopDTO.id" view-type="list" type-code="ACCESS057" />
          </QupListItem>
        </QupList>
      </c-title>
    </template>
    <c-title title="流程审批信息">
      <QupList :column="3" sep="：" default-value="" label-position="right" label-width="140">
        <QupListItem :value="detail.createBy" label="申请人" />
        <QupListItem :value="detail.createTime" label="申请时间" />
        <QupListItem :value="detail.applyNo" label="BPM单号" />
        <QupListItem label="客户经理档案提报原始表单" label-width="180px" :span="24">
          <c-file-list :uploadable="false" :editable="false" :model-id="id" view-type="list" type-code="ACCESS080" />
        </QupListItem>
        <!-- <QupListItem label="办事处审批结果" :value="detail.officeReviewResult" dict-type-code="REVIEW_RESULT" :prop-enum="{domainCode:'marketing',appCode:'slm'}" /> -->
        <!-- <QupListItem :value="detail.officeReviewTime" label="办事处审批结束时间" /> -->
        <!-- <QupListItem :value="detail.officeReviewAdvice" label="办事处审批意见" :span="24" /> -->
        <!-- <QupListItem :value="detail.officeAccountingReviewAdvice" label="办事处会计处理意见" :span="24" /> -->
        <!-- <QupListItem label="档案科审核结果" :value="detail.fileReviewResult" dict-type-code="REVIEW_RESULT" :prop-enum="{domainCode:'marketing',appCode:'slm'}" /> -->
        <!-- <QupListItem :value="detail.fileReviewTime" label="档案科审核结束时间" /> -->
        <!-- <QupListItem :value="detail.fileReviewAdvice" label="档案科审核意见" :span="24" /> -->
        <!-- <QupListItem :value="detail.authorityReviewTime" label="系统权限处理审核时间" :span="24" /> -->
        <!-- <QupListItem :value="detail.authorityReviewAdvice" label="系统权限处理审核意见" :span="24" /> -->
      </QupList>
      <Options :data="detail.opinionDTOS" />
    </c-title>
    <div class="btn-center">
      <c-button type="primary" @click="handleGoBack">返回</c-button>
    </div>
  </c-back-wrap>
</template>
<script>
import { archiveDetail } from '@/api/channelTask2/newArchive'
import AddrTable from '../../components/AddrTable'
import ContactsTable from '../../components/ContactsTable'
import PartnershipTable from '../../components/PartnershipTable'
import DistributionTable from '../../components/DistributionTable'
import Options from '../../components/Options'
import ShopContactTable from './ShopContactTable'
import ShopTable from './ShopTable'

export default {
  name: 'Detail',
  components: {
    AddrTable,
    ContactsTable,
    PartnershipTable,
    DistributionTable,
    Options,
    ShopContactTable,
    ShopTable
  },
  props: {
    id: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      detail: {},
      loading: false
    }
  },
  computed: {
    shopDTO() {
      return this.detail.shopDTO || {}
    },
    hasIsMarketConnect() {
      return [1, '1'].includes(this.detail.isMarketConnect)
    },
    // 是否接管
    isTakeOver() {
      return this.hasIsMarketConnect && [1, '1'].includes(this.detail.isTakeOverTheOriginalStore)
    },
    customerShopData() {
      return this.detail.shopDTOS || []
    },
    shopContactsData() {
      return (this.detail.contactDTOS || []).filter(e => [3, '3'].includes(e.contactScope))
    },
    hasShop() {
      return this.shopContactsData.some(e => !!e.shopCode)
    }
  },
  created() {
    this.getDetailData()
  },
  methods: {
    getDetailData() {
      this.loading = true
      return archiveDetail(this.id).then(res => {
        this.detail = res.data
      }).finally(() => {
        this.loading = false
      })
    },
    handleGoBack() {
      this.$pageStack.pop()
    }
  }
}
</script>
